// 封装cookie对应的方法 常用的对应的key和value expires过期时间  path
//set的方法
export function  setCookie(key, value) {
    const d = new Date();
    d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
    const expires = "expires=" + d.toGMTString();
    document.cookie = key + "=" + value + "; " + expires;
}
// get的方法 获取对应key的cookie值
// username=zhangsan;age=lisi
// 获取cookie
export function getCookie(key) {
    const name = key + "=";
    const ca = document.cookie.split(';');
    for (let i = 0; i < ca.length; i++) {
        const c = ca[i].trim();
        if (c.indexOf(name) === 0) {
            return c.substring(name.length, c.length);
        }
    }
}
//remove 间隔几天以后过期
export function removeCookie(key, day) {
    var date = new Date()
    date.setDate(date.getDate + day)
    document.cookie = encodeURIComponent(key) + '=;expires=' + date
}